﻿/////////////////////////////////////////////////////////
// Author   : huangzhiming
// Date     : 11/18/2011 9:34:49 AM
// Usage    : 表情帮助类
/////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TM.QWeibo.Client.Helper
{
    public class FaceHelper
    {
        public class Face {
            public string Key { get; set; }
            public string Tag { get; set; }
            public string FacePath { get; set; }
        }

        #region 私有属性

        /// <summary>
        /// 表情文件扩展名
        /// </summary>
        const string FaceImageExt = ".png";
        /// <summary>
        /// 表情文件目录
        /// </summary>
        const string FaceImageDir = "/Resource/Face";

        #endregion

        /// <summary>
        /// 表情名字
        /// </summary>
        private static readonly List<string> FaceKeys = new List<string> { 
            "no", "ok", "乒乓", "便便", "偷笑", "傲慢", "再见", "冷汗", "凋谢", "刀", 
            "勾引", "发呆", "发怒", "发抖", "可怜", "可爱", "右哼哼", "右太极", "吐", 
            "吓", "咒骂", "咖啡", "哈欠", "啤酒", "嘘", "回头", "困", "坏笑", "大兵", 
            "大哭", "太阳", "亲亲","奋斗", "呲牙", "委屈", "骷髅","害羞", "尴尬", "左哼哼", "左太极", "差劲", 
            "弱", "强", "得意", "微笑", "心碎", "快哭了", "怄火", "惊恐", "惊讶", "憨笑", 
            "抓狂", "折磨", "抠鼻", "抱拳", "拥抱", "拳头", "挥手", "握手", "撇嘴", "擦汗", 
            "敲打", "晕", "月亮", "流汗", "流泪", "激动", "炸弹", "爱你", "爱心", "爱情",
            "猪头", "献吻", "玫瑰", "瓢虫", "疑问", "白眼", "睡", "磕头", "示爱", "礼物", 
            "篮球", "糗大了", "胜利", "色", "菜刀", "蛋糕", "街舞", "衰", "西瓜", "调皮", 
            "足球", "跳绳", "跳跳", "转圈", "鄙视", "酷", "闪电", "闭嘴", "阴险", "难过", 
            "飞吻", "饥饿", "饭",  "鼓掌" };

        /// <summary>
        /// 表情名字
        /// </summary>
        private static readonly List<string> FaceASCIIKeys = new List<string> { 
            "no", "ok", "bingbing", "bianbian", "touxiao", "aoman", "zaijian", "lenghan", "diaoxie", "dao", 
            "gouying", "fadai", "fanu", "fadou", "kelian", "keai", "youhengheng", "youtaiji", "tu", 
            "xia", "zouma", "kafei", "haqian", "pijiu", "xu", "huitou", "kun", "huaixiao", "dabin", 
            "daku", "taiyang", "qinqin","feidou", "ciya", "weiqu", "kulou","haixiu", "ganga", "zuohengheng", "zuotaiji", "chajing", 
            "ruo", "qiang", "deyi", "weixiao", "xinsui", "kuaikule", "naohuo", "jingkong", "jingya", "hanxiao", 
            "zhuakuang", "zhemo", "koubi", "baoquan", "yongbao", "quantou", "huishou", "woshou", "piezui", "chahan", 
            "qiaoda", "yun", "yueliang", "liuhang", "liulei", "jidong", "zhadan", "aini", "aixin", "aiqing",
            "zhutou", "xiangwen", "meigui", "piaochong", "yiwen", "baiyan", "sui", "ketou", "shiai", "liwu", 
            "lanqiu", "choudale", "shengli", "se", "caidao", "dangao", "jiewu", "shuai", "xigua", "tiaopi", 
            "zuqiu", "tiaoshen", "tiaotiao", "zhuanquan", "bishi", "ku", "shangdian", "bizhui", "yingxiang", "nanguo", 
            "feiwen", "jie", "fan",  "guzhang" };

        /// <summary>
        /// 获取表情的路径
        /// </summary>
        /// <returns></returns>
        public static string GetFaceUrl(string facekey)
        {
            return string.Format("{0}/{1}{2}",FaceImageDir,facekey,FaceImageExt);
        }

        /// <summary>
        /// 获取表情的路径
        /// </summary>
        /// <returns></returns>
        public static string GetFaceUrlFromChinese(string facekey)
        {
            for (int i = 0; i < FaceKeys.Count; i++)
            {
                if(string.Equals(facekey,FaceKeys[i]))
                {
                    facekey = FaceASCIIKeys[i];
                    break;
                }
            }
            return string.Format("{0}/{1}{2}", FaceImageDir, facekey, FaceImageExt);
        }

        /// <summary>
        /// 判断表情是否存在
        /// </summary>
        /// <param name="faceCode"></param>
        /// <returns></returns>
        public static bool Exist(string faceCode)
        {
            return FaceKeys.Contains(faceCode);
        }

        /// <summary>
        /// 表情数据
        /// </summary>
        /// <returns></returns>
        /// 
        public static List<Face> Faces() {
            var rs = new List<Face>();
            for (int i = 0; i < FaceASCIIKeys.Count; i++)
            {
                var f = FaceASCIIKeys[i];
                rs.Add(new Face
                {
                    Key=f,
                    Tag=FaceKeys[i],
                    FacePath=GetFaceUrl(f)
                });
            }
            return rs;
        }

    }
}
